<?php

namespace App\models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $table = 'order_goods';
    protected $primaryKey = 'rec_id';
    public $timestamps = false; //关闭模型自动维护时间戳
    public static $orderStatus = ['未确认','已确认','已取消','无效','退货'];
    public static $shippingStatus = ['未发货','已发货','已收货','备货中'];
    public static $payStatus = ['未付款','付款中','已付款'];


    public function info()
    {
        return $this->hasOne('App\models\OrderInfo','order_id','order_id');
    }
    public static function getList()
    {
        return self::join('order_info','order_goods.order_id','=','order_info.order_id')
            ->get()
            ->toArray();
    }
    public static function getOne($id)
    {
        return self::join('order_info','order_goods.order_id','=','order_info.order_id')
            ->find($id)
            ->toArray();
    }
    // 订单状态
    public static function orderStatus($key)
    {
        return self::$orderStatus[$key];
    }
    //商品配送情况
    public static function shippingStatus($key)
    {
        return self::$shippingStatus[$key];
    }
    //支付状态
    public static function payStatus($key)
    {
        return self::$payStatus[$key];
    }
}
